package com.seventh.parkingrent.commens;

import com.seventh.parkingrent.exception.CustomException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(CustomException.class)
    public Result handlerCustomexception(CustomException e){
        log.warn(e.getMessage());
        return Result.fail(e.getMessage());
    }


    @ExceptionHandler(Exception.class)
    public Result handlerExcpetion(Exception e){
        log.warn(e.getMessage());
        return Result.fail("系统好像开了个小差");
    }
}
